home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1998 May
/
Macworld (1998-05).dmg
/
Shareware World
/
Comms & Internet
/
ImageMapper v3.0
/
Goodies
/
Java
/
HighlightedImageMap(Original)
/
HighlightableLink.java
< prev
next >
Wrap
Text File
|
1996-10-10
|
1KB
|
89 lines
import java.awt.*;
import java.applet.Applet;
import java.net.URL;
/*
*
* HighlightableLink
*
*/
class HighlightableLink extends Canvas
{
public HighlightedImageMap applet=null;
Image normal;
Image highlighted;
String alt;
String target;
URL url;
boolean active=false;
public HighlightableLink(int x, int y,
int width, int height,
Image normal, Image highlighted,
URL url, String alt, String target, HighlightedImageMap applet)
{
reshape(x,y+50,width,height);
move(x,y);
this.normal=normal;
this.highlighted=highlighted;
this.url=url;
this.alt=alt;
this.target=target;
this.applet=applet;
}
public void paint(Graphics g)
{
if (applet.nloaded && applet.hloaded)
if (active)
g.drawImage(highlighted,0,0,this);
else
g.drawImage(normal,0,0,this);
else
{
g.drawRect(0,0,size().width-1,size().height-1);
g.drawString(alt,2,(g.getFontMetrics().getHeight()>>1)+size().height/2);
}
}
public void update(Graphics g)
{
paint(g);
}
public boolean mouseEnter(Event evt, int x, int y)
{
active=true;
applet.showStatus(url.toString());
repaint();
return true;
}
public boolean mouseExit(Event evt, int x, int y)
{
active=false;
repaint();
return true;
}
public boolean mouseDown(Event evt, int x, int y)
{
//Use framename if given, otherwise default frame is target
if (!target.equals(""))
applet.getAppletContext().showDocument(url,target);
else
applet.getAppletContext().showDocument(url);
return true;
}
}